package cn.bob.feign;

import cn.bob.dto.BuyNumDto;
import cn.bob.dto.SelectByMovieDto;
import cn.bob.result.JsonResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.validation.Valid;

@FeignClient(name = "service-movie",fallbackFactory = SentinelClientFallbackFactory.class
,path = "/movieTicket")
public interface MovieServer {
    /**
     * 查询所有电影票
     * @return
     */
    @RequestMapping(value = "/list",method = RequestMethod.GET)
    JsonResult list();

    /**
     * 购买接口
     */
    @RequestMapping(value = "/buy",method = RequestMethod.POST)
   JsonResult buy(@RequestBody @Valid BuyNumDto buyNumDto);

    /**
    * 根据电影id查询接口
    */
    @RequestMapping(value = "/selectByMovie",method = RequestMethod.POST)
    JsonResult selectByMovie(@RequestBody @Valid SelectByMovieDto selectByMovieDto);

    /**
     * 查询单条
     * @param id
     * @return
     */
    @RequestMapping(value = "/{id}",method = RequestMethod.GET)
     JsonResult get(@PathVariable("id")Long id);

    @RequestMapping(value = "/randomMovie/{userId}",method = RequestMethod.POST)
    JsonResult randomMovie(@PathVariable("userId")  Long userId);

    @RequestMapping(value = "/seeMovie",method = RequestMethod.POST)
    JsonResult seeMovie(@RequestBody @Valid BuyNumDto buyNumDto);
}


